package com.atguigu.ssyx.acl.controller;

import com.atguigu.ssyx.common.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * @author chentengfei
 * @desc 登录相关的接口
 * @date 2023-06-09 13:39:40
 */

@Api(tags = "登录接口")
@RestController
@RequestMapping("/admin/acl/index/")
// @CrossOrigin  //该注解用于解决跨域
public class IndexController {

    /**对应前端页面地址: ssyx/guigu-ssyx/ssyx-admin/src\api/user.js*/

    /***
     * http://localhost:8201/admin/acl/index/login
     * login登录
     * @author chentengfei
     * @date 2023/6/9 13:42
     * @return com.atguigu.ssyx.common.result.Result
     */
    @ApiOperation("登录")
    @PostMapping("login")
    public Result login(){
        //返回token值
        Map<String,String> map = new HashMap<>();
        map.put("token","token-admin");
        return Result.ok(map);
    }

    /***
     * url: '/admin/acl/index/info'
     * getInfo 获取信息
     * @author chentengfei
     * @date 2023/6/9 13:44
     * @return com.atguigu.ssyx.common.result.Result
     */
    @ApiOperation("获取信息")
    @GetMapping("info")
    public Result info(){
        Map<String,String> map = new HashMap<>();
        map.put("name", "admin");
        map.put("avatar","https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif");
        return Result.ok(map);
    }

    /***
     * url: '/admin/acl/index/logout'
     * logout 退出
     * @author chentengfei
     * @date 2023/6/9 13:44
     * @return com.atguigu.ssyx.common.result.Result
     */
    @ApiOperation("退出")
    @PostMapping("logout")
    public Result logout(){
        return Result.ok(null);
    }
}
